package com.example.mapp;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.*;

import com.example.entity.maintenance.TractionHalfMon;
import com.example.entity.maintenance.TractionHalfYear;
import com.example.entity.maintenance.TractionQuarter;
import com.example.entity.maintenance.TractionYear;
import com.example.ext.entity.maintenance.ExtTractionHalfMon;
import com.example.mapp.buildSql.MaintMappSql;

/**
 * Created by douyx on 2017/10/29.
 */
@Mapper
public interface TractionMapp {
	/**
	 * 新增曳引电梯半月保数据
	 *
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into traction_half_mon (emergency_electric_operation,station_call,accuracy_car_deck,anti_collision_protector,automatic_closing_device,"
			+ "automatic_reset,brake_clearance,brake_each_position,break_external_protection,bypass_device,car_alarm_device,car_door_run,car_lighting,"
			+ "car_overhaul_switch,car_top,car_top_switch,counterweight_block,display_command_button,drive_host,electric_contact,electrical_contact,"
			+ "emergency_operation_device,encoder,guide_shoe_cup,landing_sill,layer_locking_length,limiter_each_part,maintenance_end_date,maintenance_start_date,"
			+ "maintenance_user_sign_id1,maintenance_user_sign_id2,pit_eenvironment,pit_stop,room_environment,safe_user_sign_id2,safe_user_sign_time,status,"
			+ "type,well_illumination,elevator_num,safe_user_name,maintenance_user_name,maintenance_user_name2," +
			"maintenance_user_id1,maintenance_user_id2,maintenance_party_id,is_in_time_maint,maintenancen_used_time,change_info,summary,xcfhcs,ldbh,other_photos)"
			+ " VALUES (#{emergencyElectricOperation}," +
			" #{stationCall},#{accuracyCarDeck},#{antiCollisionProtector},#{automaticClosingDevice},"
			+ "#{automaticReset},#{brakeClearance},#{brakeEachPosition},#{breakExternalProtection},#{bypassDevice},#{carAlarmDevice},#{carDoorRun},#{carLighting},"
			+ "#{carOverhaulSwitch},#{carTop},#{carTopSwitch},#{counterweightBlock},#{displayCommandButton},#{driveHost},#{electricContact},#{electricalContact},"
			+ "#{emergencyOperationDevice},#{encoder},#{guideShoeCup},#{landingSill},#{layerLockingLength},#{limiterEachPart},#{maintenanceEndDate},"
			+ "#{maintenanceStartDate},#{maintenanceUserSignId1},#{maintenanceUserSignId2},#{pitEenvironment},#{pitStop},#{roomEnvironment},#{safeUserSignId2},"
			+ "#{safeUserSignTime},#{status},#{type},#{wellIllumination},#{elevatorNum},#{safeUserName},#{maintenanceUserName},#{maintenanceUserName2}," +
			"#{maintenanceUserId1},#{maintenanceUserId2}," +
			"#{maintenancePartyId},#{isInTimeMaint},#{maintenancenUsedTime},#{changeInfo},#{summary},#{xcfhcs},#{ldbh},#{otherPhotos}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addTractionHalfMon2(TractionHalfMon tractionHalfMon) throws Exception;
	/**
	 * 新增曳引电梯半月保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into traction_half_mon (emergency_electric_operation,station_call,accuracy_car_deck,anti_collision_protector,automatic_closing_device,"
			+ "automatic_reset,brake_clearance,brake_each_position,break_external_protection,bypass_device,car_alarm_device,car_door_run,car_lighting,"
			+ "car_overhaul_switch,car_top,car_top_switch,counterweight_block,display_command_button,drive_host,electric_contact,electrical_contact,"
			+ "emergency_operation_device,encoder,guide_shoe_cup,landing_sill,layer_locking_length,limiter_each_part,maintenance_end_date,maintenance_start_date,"
			+ "maintenance_user_sign_id1,maintenance_user_sign_id2,pit_eenvironment,pit_stop,room_environment,"
			+ "type,well_illumination,elevator_num,safe_user_name,maintenance_user_name,maintenance_user_name2," +
			"maintenance_user_id1,maintenance_user_id2,maintenance_party_id,is_in_time_maint,maintenancen_used_time,change_info,summary,xcfhcs,ldbh,other_photos)"
			+ " VALUES (#{emergencyElectricOperation}," +
			" #{stationCall},#{accuracyCarDeck},#{antiCollisionProtector},#{automaticClosingDevice},"
			+ "#{automaticReset},#{brakeClearance},#{brakeEachPosition},#{breakExternalProtection},#{bypassDevice},#{carAlarmDevice},#{carDoorRun},#{carLighting},"
			+ "#{carOverhaulSwitch},#{carTop},#{carTopSwitch},#{counterweightBlock},#{displayCommandButton},#{driveHost},#{electricContact},#{electricalContact},"
			+ "#{emergencyOperationDevice},#{encoder},#{guideShoeCup},#{landingSill},#{layerLockingLength},#{limiterEachPart},#{maintenanceEndDate},"
			+ "#{maintenanceStartDate},#{maintenanceUserSignId1},#{maintenanceUserSignId2},#{pitEenvironment},#{pitStop},#{roomEnvironment},"
			+ "#{type},#{wellIllumination},#{elevatorNum},#{safeUserName},#{maintenanceUserName},#{maintenanceUserName2}," +
			"#{maintenanceUserId1},#{maintenanceUserId2}," +
			"#{maintenancePartyId},#{isInTimeMaint},#{maintenancenUsedTime},#{changeInfo},#{summary},#{xcfhcs},#{ldbh},#{otherPhotos}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addTractionHalfMon(TractionHalfMon tractionHalfMon) throws Exception;


	/**
	 * 更新曳引电梯半月保数据
	 * @param map
	 * @return
	 * @throws Exception
	 */
	@Update("update traction_half_mon set safe_user_sign_id2=#{safeUserSignId2}," +
			"safe_user_name=#{safeUserName},safe_user_sign_time=#{safeUserSignTime}," +
			"status=#{status},used_party_opt=#{usedPartyOpt}  where id=#{elevatoriMonId} ")
	public void updateEscalatorHalfMon(Map<String,Object> map) throws Exception;
	/**
	 * 获取曳引电梯维保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@SelectProvider(type = MaintMappSql.class, method = "findTractionList")
	List<ExtTractionHalfMon> findTractionList(ExtTractionHalfMon tractionHalfMon) throws Exception;

	@Select(" SELECT * from traction_half_mon where id = #{id}")
	TractionHalfMon queryTractionHalfMon(Long id) throws Exception;
	
	/**
	 * 新增曳引电梯季度保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into traction_quarter (brake_lining,car_shoe_roller,door_guide_shoe,electrical_safety_device,encoder,energy_dissipation_buffer,"
			+ "fire_switch,half_mon_id,layer_dynamic_contact,limiter_wheel_safety,limiter_wheel_wire,lubricating_oil,traction_wheel_groove,transmission_steel) "
			+ "VALUES (#{brakeLining},#{carShoeRoller},#{doorGuideShoe},#{electricalSafetyDevice},#{encoder},#{energyDissipationBuffer},#{fireSwitch},#{halfMonId},"
			+ "#{layerDynamicContact},#{limiterWheelSafety},#{limiterWheelWire},#{lubricatingOil},#{tractionWheelGroove},#{transmissionSteel}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addTractionQuarter(TractionQuarter tractionQuarter) throws Exception;

	@Select(" SELECT * from traction_quarter where half_mon_id = #{halfMonId}")
	TractionQuarter queryTractionQuarter(Long halfMonId) throws Exception;
	
	/**
	 * 新增曳引电梯半年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into traction_half_year (brake_action_monitoring,all_instrument,bearing_department,buffer_distance,compensating_rope,"
			+ "compensation_link,control_cabinet_terminals,door_open_limit_device,driving_wheel,limit_switch,limiter_wheel_wire,limiter_wire_rope,"
			+ "motor_reducer_coupling,quarter_id,rope_combination,traction_wheel_groove) VALUES (#{brakeActionMonitoring},#{allInstrument},#{bearingDepartment},"
			+ "#{bufferDistance},#{compensatingRope},#{compensationLink},#{controlCabinetTerminals},#{doorOpenLimitDevice},#{drivingWheel},#{limitSwitch},"
			+ "#{limiterWheelWire},#{limiterWireRope},#{motorReducerCoupling},#{quarterId},#{ropeCombination},#{tractionWheelGroove}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addTractionHalfYear(TractionHalfYear tractionHalfYear) throws Exception;

	@Select(" SELECT * from traction_half_year where quarter_id = #{quarterId}")
	TractionHalfYear queryTractionHalfYear(Long quarterId) throws Exception;
	
	/**
	 * 新增曳引电梯年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into traction_year (bottom_mounting_bolt,brake_capacity,brake_plunger,buffer,car_emergency_test,car_guide_bracket,car_guide_rail,"
			+ "car_weighing_device,contactor_contact,device_and_sill,half_year_id,insulation_performance_test,limiter_safety_clamp_linkage_test,safety_clamp_holder,"
			+ "top_mounting_bolt,traveling_cable,uplink_overspeed_protection_test,year_lubricating_oil) VALUES (#{bottomMountingBolt},#{brakeCapacity},#{brakePlunger},"
			+ "#{buffer},#{carEmergencyTest},#{carGuideBracket},#{carGuideRail},#{carWeighingDevice},#{contactorContact},#{deviceAndSill},#{halfYearId},"
			+ "#{insulationPerformanceTest},#{limiterSafetyClampLinkageTest},#{safetyClampHolder},#{topMountingBolt},#{travelingCable},#{uplinkOverspeedProtectionTest},"
			+ "#{yearLubricatingOil}) ")
	public Long addTractionYear(TractionYear tractionYear) throws Exception;
	
	@Select(" SELECT * from traction_year where half_year_id = #{halfYearId}")
	TractionYear queryTractionYear(Long halfYearId) throws Exception;
}
